import type {Router, RouteRecordRaw} from 'vue-router';
import {createRouter, createWebHashHistory} from "vue-router";

// 1. 定义路由
const routes: Array<RouteRecordRaw> = [
    {
        path: '/',
        name: 'Home',
        component: () => import('@/views/home/home.vue'),
        children: [
            {
                path: '',
                name: 'Dashboard',
                component: () => import('@/views/dashboard/dashboard.vue')
            },
            {
                path: '/sys/user/:id?',
                name: 'SysUser',
                component: () => import('@/views/sys/user/user.vue')
            },
            {
                path: '/:catchAll(.*)', // 通配符路由
                name: '404',
                component: () => import('@/views/error/404.vue')
            }
        ]
    },
    {
        path: '/login',
        name: 'Login',
        component: () => import('@/views/login/login.vue')
    },
    {
        path: '/:catchAll(.*)', // 通配符路由
        name: '404',
        component: () => import('@/views/error/404.vue')
    }
];


//  创建路由实例并传递routes配置
const router: Router = createRouter({
    // 内部提供了 history 模式的实现。为了简单起见，我们在这里使用 hash 模式。
    history: createWebHashHistory(),
    routes, // `routes: routes` 的缩写
});

export default router;